//: Playground - noun: a place where people can play

import Cocoa
//类型别名
typealias NSInteger = Int
var inta : NSInteger = 0

//int
var a = 1
var b : Int = 1

//Float,Double
var c = 3.14
var d : Float = 2.0
var e : Double = 2.1

//bool
var f : Bool
f = true

//-----------------------------------------String字符串---------------------------------------------------------
var g : String = "江"
//后面追加字符
g.append("湖")
//插入字符
var h = "大家好，我叫\(g)，谢谢"
//字符串连接
var i = g + "李"
//字符串长度
print(g.count,i.count)

//------------------------------------------数组---------------------------------------------------------
var arr = [Int]()
var arr1 : [Int] = [1,2,3]
//创建重复元素的数组
var arr2  = [Int](repeating: 23, count: 20)
var arr3  = [String](repeating: "你好", count: 2)
//修改数组
arr.append(20)
arr += [230]
//修改元素的值
arr[0] = 30
//遍历数组
for obj in arr {
    print(obj)
}
//有索引的遍历
for (index,obj) in arr.enumerated() {
    print("下标为\(index) 值为\(obj)")
}
//合并数组
var arr4 = arr1 + arr2
//判断数组是否为空
if arr4.isEmpty {
    print("arr4为空")
}else {
    print("arr4不为空")
}
//--------------------------------------字典------------------------------------------------------------------
var dic = [String:String]()

var dic1 : [Int:String] = [1:"小米"]
var dic2 : [String:Any] = ["name":"小米","age":"19","arr":[1,"ann",3,4]]

var dic3 : Dictionary = ["name":"小米","age":"19","arr":""]

//字典增加和修改
//修改
var old = dic1.updateValue("小黑", forKey: 1)
//增加
var old1 = dic1.updateValue("小兰", forKey: 2)
//增加
var old2 = dic1.updateValue("小白", forKey: 3)
print(dic1)
//移除
var removed = dic1.removeValue(forKey: 1)
dic1[2] = nil
print(dic1)

//遍历字典
for (key,value) in dic2.enumerated() {
    print("key:\(key) value:\(value)")
}

//字典转换成数组
var dicKeys = [String](dic2.keys)
var dicvalues = [Any](dic2.values)
print(dicKeys)
print(dicvalues)


//-------------------------------------------元组------------------------------------------------------

var group = (name:"江湖",age:11,2.2,3)
//修改
group.2 = 33
print(group.name,group.age)


//
















